# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=cairo

pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.12.16
pkgrel=2
pkgdesc="Cairo vector graphics library (mingw-w64)"
arch=('any')
url="http://cairographics.org"
license=("LGPL, MPL")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
    "${MINGW_PACKAGE_PREFIX}-pkg-config"
    "${MINGW_PACKAGE_PREFIX}-glib2"
    "${MINGW_PACKAGE_PREFIX}-librsvg"
    "${MINGW_PACKAGE_PREFIX}-gtk2"
    "${MINGW_PACKAGE_PREFIX}-poppler"
    "${MINGW_PACKAGE_PREFIX}-ghostscript"
    )
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs"
    "${MINGW_PACKAGE_PREFIX}-freetype"
    "${MINGW_PACKAGE_PREFIX}-fontconfig"
    "${MINGW_PACKAGE_PREFIX}-lzo2"
    "${MINGW_PACKAGE_PREFIX}-zlib"
    "${MINGW_PACKAGE_PREFIX}-pixman")
optdepends=("mingw-w64-glib2: libcairo-gobject")
options=('strip' 'staticlibs')
source=("http://cairographics.org/releases/cairo-${pkgver}.tar.xz"
    0001-no-need-to-define-ssize_t-on.v2.mingw.patch
    0009-standalone-headers.mingw.patch
    0010-binary-mode-in-any2ppm.mingw.patch
    0012-more-binary-mode.mingw.patch)
sha1sums=('4f6e337d5d3edd7ea79d1426f575331552b003ec'
          '08c44ff2b0caf61b8f339c01059da88a1201be48'
          '58c548d2791ba20dd7f6e328ff596f746df3aa10'
          '47c065255a717cac152d4cf090906a817444b25c'
          '32d6549232829cbe6cc2e55b79e51d118e796c50')

prepare() {
  cd "${srcdir}"/${_realname}-${pkgver}
  patch -p1 -i ${srcdir}/0001-no-need-to-define-ssize_t-on.v2.mingw.patch
  patch -p1 -i ${srcdir}/0009-standalone-headers.mingw.patch
  patch -p1 -i ${srcdir}/0010-binary-mode-in-any2ppm.mingw.patch
  patch -p1 -i ${srcdir}/0012-more-binary-mode.mingw.patch
  
  autoreconf -fi
}

build() {
  export lt_cv_deplibs_check_method='pass_all'
    mkdir -p "${srcdir}/build-${MINGW_CHOST}"
    cd "${srcdir}/build-${MINGW_CHOST}"
    CFLAGS+=" -mms-bitfields"
    "${srcdir}"/${_realname}-${pkgver}/configure \
      --prefix=${MINGW_PREFIX} \
      --build=${MINGW_CHOST} \
      --host=${MINGW_CHOST} \
      --enable-win32 \
      --enable-win32-font \
      --enable-png \
      --enable-shared \
      --enable-static \
      --enable-gobject \
      --enable-tee \
      --disable-xlib \
      --disable-xcb \
      --enable-fc \
      --enable-ft \
    ac_cv_prog_GS=${MINGW_PREFIX}/bin/gsc
    make
}

package() {
    cd "${srcdir}/build-${MINGW_CHOST}"
    make DESTDIR="$pkgdir" install
    #rm -r "${pkgdir}${MINGW_PREFIX}/share"
}
